package cn.edu.cdu.group4nb.controller;

import cn.edu.cdu.group4nb.po.Position;
import cn.edu.cdu.group4nb.service.PositionService;
import cn.edu.cdu.group4nb.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class PositionController {
    @Autowired
    private PositionService positionService;
    @ResponseBody
    @GetMapping("/PositionManager/selectPosition")
    public List<Map<String, Object>> selectPosition (){
        return positionService.selectPosition();
    }
    @ResponseBody
    @PostMapping("/PositionManager/addPosition")
    public Boolean insertPosition(@RequestBody Position position){
        return positionService.insertPosition(position);
    }
    @ResponseBody
    @PostMapping("/PositionManager/delPosition")
    public Boolean delPosition(@RequestBody int[] position_id){
        return positionService.delPosition(position_id);
    }
    @ResponseBody
    @PostMapping("/PositionManager/updPosition")
    public Boolean updInstitution(@RequestBody  Position position){
        String jsonResult =com.alibaba.fastjson.JSON.toJSONString(position);
        System.out.print(jsonResult);
        return positionService.updPosition(position);
    }
    @ResponseBody
    @PostMapping("/PositionManager/selectPositionById")
    public List<Map<String, Object>> selectPositionById(@RequestBody Position position){
        return positionService.selectPositionById(position);
    }
}
